﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using T.FAS.Runtime.Base.Entity;
using T.FAS.Runtime.Expression.Entity;
using T.ServiceComponent.Config.Client;
using  T.ServiceFramework.ServiceGateway.Client;

namespace T.FAS.Runtime.Expression.Plugin
{
    public static class UserUtil
    {
        public static string GetDingDingIdByUserId(string userId)
        {

            Dictionary<string, string> parameter = new Dictionary<string, string>();
            parameter.Add("param", JsonConvert.SerializeObject(new Dictionary<string, string> { { "UserId", userId }, { "TPType", "9" }, { "TAppID", "EE458DB3-65D7-4710-B666-65CE6394AF5F" } }));
            TResponse<string> response = new SGHttpClient(true).PostCurrentIDC<string>("SYSSrv-ITPUserService-GetTPUserIdByUserId", parameter, 10);

            if (response.state == "1")
            {
                return response.data;
            }

            return null;
        }
        /// <summary>
        /// 钉钉AgentID
        /// </summary>       
        public static string DingTalkAgentID
        {
            get
            {
                var defaultValue = "1256637521";
                
                try
                {
                    string val = ConfigManager.GetConfigValue("Fas.Expr.DingTalkAgentID");
                    if (string.IsNullOrEmpty(val))
                    {
                        return defaultValue;
                    }
                    return val;
                }
                catch
                {
                    return defaultValue;
                }
            }
        }
    }
}
